const { pool, router, Result } = require('../connect')

router.get('/', (req, res) => {
  console.log('login');
  pool.getConnection((err, conn) => {
    if (err) Result({ code: 0, message: '获取失败', data: err })
    conn.query('SELECT * FROM stu_tab1', (e, r) => {
      if (e) throw e
      res.json(new Result({ data: r }))
    })
    pool.releaseConnection(conn) // 释放连接池，等待别的连接使用
  })
})

module.exports = router